<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.14.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>DM-CtrlH7-BF-DevProgram: bsp_log</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="DMBF-Black.png"/></td>
  <td id="projectalign">
   <div id="projectname">DM-CtrlH7-BF-DevProgram<span id="projectnumber">&#160;beta 0.1</span>
   </div>
   <div id="projectbrief">C.ONE Studio Damiao Development Board Framework</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.14.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search',true);
  $(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(function(){initNavTree('md_bsp_2log_2bsp__log.html','',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title">bsp_log </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="autotoc_md15"></a></p>
<p align="right"></p>
<p><a href="#" onclick="location.href='mai'+'lto:'+'neo'+'zn'+'g1@'+'hn'+'u.e'+'du'+'.cn'; return false;">neozn<span class="obfuscator">.nosp@m.</span>g1@h<span class="obfuscator">.nosp@m.</span>nu.ed<span class="obfuscator">.nosp@m.</span>u.cn</a></p>
<h1 class="doxsection"><a class="anchor" id="autotoc_md16"></a>
使用说明</h1>
<p>bsp_log是基于segger RTT实现的日志打印模块。</p>
<p>推荐使用<span class="tt"><a class="el" href="bsp__log_8h_source.html">bsp_log.h</a></span>中提供了三级日志：</p>
<div class="fragment"><div class="line"><span class="preprocessor">#define LOGINFO(format,...)</span></div>
<div class="line"><span class="preprocessor">#define LOGWARNING(format,...)</span></div>
<div class="line"><span class="preprocessor">#define LOGERROR(format,...)</span></div>
</div><!-- fragment --><p>分别用于输出不同等级的日志。注意RTT不支持直接使用<span class="tt">f</span>进行浮点格式化,要使用<span class="tt">void Float2Str(char *str, float va);</span>转化成字符串之后再发送。</p>
<p><b>若想启用RTT，必须通过<span class="tt">launch.json</span>的<span class="tt">debug-jlink</span>启动调试（不论使用什么调试器）。</b> 按照<span class="tt">VSCode+Ozone环境配置</span>完成配置之后的cmsis dap和daplink是可以支持Jlink全家桶的。</p>
<p>另外，若你使用的是cmsis-dap和daplink，**请在 <em>jlink</em> 调试任务启动之后再打开<span class="tt">log</span>任务。**（均在项目文件夹下的.vsocde/task.json中，有注释自行查看）。否则可能出线RTT viewer无法连接客户端的情况。</p>
<p>在ozone中查看log输出，直接打开console调试任务台和terminal调试中断便可看到调试输出。</p>
<blockquote class="doxtable">
<p>由于ozone版本的原因，可能出现日志不换行或没有颜色。 </p>
</blockquote>
<h1 class="doxsection"><a class="anchor" id="autotoc_md17"></a>
自定义输出</h1>
<p>你也可以自定义输出格式，详见Segger RTT的文档。</p>
<div class="fragment"><div class="line"><span class="keywordtype">int</span> printf_log(<span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, ...);</div>
<div class="line"><span class="keywordtype">void</span> Float2Str(<span class="keywordtype">char</span> *str, <span class="keywordtype">float</span> va); <span class="comment">// 输出浮点需要先用此函数进行转换</span></div>
</div><!-- fragment --><p>调用第一个函数，可以通过jlink或dap-link向调试器连接的上位机发送信息，格式和printf相同，示例如下：</p>
<div class="fragment"><div class="line">printf_log(<span class="stringliteral">&quot;Hello World!\n&quot;</span>);</div>
<div class="line">printf_log(<span class="stringliteral">&quot;Motor %d met some problem, error code %d!\n&quot;</span>,3,1);</div>
</div><!-- fragment --><p>第二个函数可以将浮点类型转换成字符串以方便发送：</p>
<div class="fragment"><div class="line"><span class="keywordtype">float</span> current_feedback=114.514;</div>
<div class="line"><span class="keywordtype">char</span>* str_buff[64];</div>
<div class="line">Float2Str(str_buff,current_feedback);</div>
<div class="line">printf_log(<span class="stringliteral">&quot;Motor %d met some problem, error code %d!\n&quot;</span>,3,1);</div>
</div><!-- fragment --> </div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<div id="page-nav" class="page-nav-panel">
<div id="page-nav-resize-handle"></div>
<div id="page-nav-tree">
<div id="page-nav-contents">
</div><!-- page-nav-contents -->
</div><!-- page-nav-tree -->
</div><!-- page-nav -->
</div><!-- container -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li>
  </ul>
</div>
</body>
</html>
